In [11]:
# pow method
def pow(base, power):
    output = 1 
    for i in range(0, power):
        output *= base
    return output

In [12]:
pow(10, 2) == 100


Out[12]:
True

In [16]:
pow(10, 3) == 1000


Out[16]:
True

In [18]:
pow(10, 4) == 10000


Out[18]:
True

In [3]:
import numpy as np
import matplotlib.pyplot as plt

In [12]:
x1 = [1,2,3, 4]
y1 = [1,2,3,4]

x2 = [1,2,3,4]
y2 = [8,7,6,5]

plt.plot(x1, y1, label='Line 2')
plt.plot(x2, y2, label='Line 1')
plt.xlabel('x label')
plt.ylabel('y label')
plt.legend()
plt.show()



In [54]:
x1 = list(range(0,8,2))
y1 = [1,22,3,17]

x2 = list(range(1,9,2))


[0, 2, 4, 6]
[1, 3, 5, 7]

In [79]:
# this is a bar chart
plt.bar(x1,y1, label="bars 1")
plt.bar(x2,y2, label="bars 2")
plt.legend()
plt.show()



In [67]:
random_ages = np.random.randint(1,130,100)
bins = list(range(0,140,10))
print(bins)


[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]

In [78]:
# this is a histagram chart
plt.hist(random_ages, bins, histtype='bar', rwidth=0.6)
plt.show()



In [80]:
random_ages2 = np.random.randint(1,130,100)
plt.scatter(random_ages, random_ages2, color='r', marker='o', label='test', s=10)
plt.legend()
plt.show()
# this is a scatter plot


Stack Plot


In [94]:
days = list(range(0,15))

eating = np.random.randint(0,10,15)
sleeping = np.random.randint(0,10,15)
working = np.random.randint(0,10,15)
playing = np.random.randint(0,10,15)


# for some reason this is the only way to create labesl for our data in a stack plot
plt.plot([],[], color="g", linewidth=1, label='eating')
plt.plot([],[], color="r", linewidth=1, label='sleeping')
plt.plot([],[], color="orange", linewidth=1, label='working')
plt.plot([],[], color="b", linewidth=1, label='playing')


plt.stackplot(days, eating, sleeping, working, playing, colors=['g','r','orange','b'])
plt.title("My Random Stack Plot")
plt.xlabel("days")
plt.ylabel("activity")
plt.legend()
plt.show()


Pie Charts


In [5]:
slices=[2,2,7,13]

fig1, ax1 = plt.subplots()
labels = ['Val 1', 'Val 2', 'Val 3', 'Val 4']
ax1.pie(slices, labels=labels, explode=(0,0.2,0,0), startangle=90, autopct='%1.1f%%')
ax1.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.
plt.title("My Py Chart") # yes I know that spelling is wrong... it's a joke. Laugh damn it! 

plt.show()



In [20]:
first2x2 = np.array([[2,2],[3,3]])
second2x2 = np.array([[4,4], [5,3]])

# first2x2.dot(second2x2)

# first2x2.transpose()
# first2x2
np.linalg.det(second2x2)


Out[20]:
-7.9999999999999982

In [ ]: